<?php
class App_Validate_PasswordStrength extends Zend_Validate_Abstract {
    const INVALID = 'passwordInvalid';
    const NOT_STRONG = 'passwordNotStrong';
    
    const LENGTH = 'length';
    const UPPER = 'upper';
    const LOWER = 'lower';
    const DIGIT = 'digit';
    protected $_messageTemplates = array(
        

    );

    public function isValid($value) {
        $this->_setValue($value);
        $isValid = true;
        if(strlen($value) < 8) {
            $this->_error(self::LENGTH);
            $isValid = false;
        }
        if(! preg_match('/[A-Z]/', $value)) {
            $this->_error(self::UPPER);
            $isValid = false;
        }
        if(! preg_match('/[a-z]/', $value)) {
            $this->_error(self::LOWER);
            $isValid = false;
        }
        if(! preg_match('/\d/', $value)) {
            $this->_error(self::DIGIT);
            $isValid = false;
        }
        return $isValid;
    }
}